package com.iot.core.service.Impl;

import java.lang.reflect.InvocationTargetException;

import org.springframework.stereotype.Service;

import com.iot.core.bean.TransactionBean;
import com.iot.core.dao.TransactionRepository;
import com.iot.core.model.Transaction;
import com.iot.core.model.TransactionKey;
import com.iot.core.service.TransactionService;
import com.witsight.cassandra.service.impl.BaseCassandraServiceImpl;
import com.witsight.platform.util.lang.BeanUtil;

/**
 * 
 * @author penght
 *
 */
@Service
public class TransactionServiceImpl extends BaseCassandraServiceImpl<Transaction, TransactionKey> implements TransactionService {

	//transactionRepository
	private TransactionRepository transactionRepository;
	protected TransactionServiceImpl(TransactionRepository baseDao) {
		super(baseDao);
		transactionRepository = baseDao;
	}
	@Override
	public void Save(TransactionBean transactionBean) throws IllegalAccessException, InvocationTargetException {
		Transaction tran = new Transaction();
		//tran.setSerialNumber(transactionBean.getSerialNumber());
		//save other infomations such as IssueCatalog etc.
		BeanUtil.copyProperties(tran, transactionBean);
		//after other infomations success
		transactionRepository.save(tran);
	}

}
